<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String contextPath = request.getContextPath();
%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>마이페이지</title>
<style type="text/css">
	#wrap_detail{
		width: 700px;
		margin-left: 100px;
		margin: 0;
		color: #696969;
		line-height: normal;
		font-style: normal;
		font-family: Verdana;
		font-size: 12px;
		margin-bottom: 80px; 
	}
	#title_img{
		margin-top: 100px;
		position: relative;
		margin-left: -13px;
	}
	.my_btn{
		width:130px;
		height:30px;
		margin-right:10px;
		background-color: #2F4F4F;
		font-family: "맑은 고딕";
		font-size:9pt;
		color:white;
		border: 0;
	}
	#list{
		margin-bottom: 30px;
	}
	#list ul{
		overflow: auto;
		padding: 0;
	}
	#list li{
		float:left;
		list-style:none;
	}
	#my_main_member_buylist{
		float: left;
		width: 600px;
		margin-top: 30px;
	}
	#mypage_list_tab{
		width:600px;
	}
	#mypage_list_tab h2{
		float: left;
	}
	#board_type_list_2{
		width: 700px;
		margin-top: 8px;
	}
	#board_type_list_2 th{
		text-align:center;
		height: 30px;
	}
	#board_type_list_2 td{
		border-bottom:1px solid #d3ccbe; 
		padding:10px 0; 
		font-size:11px;
		text-align: center;
	}
	#alt{
		background:#f5f5f5;
		text-align:center; 
		padding:10px 0 10px 0; 
		border-top:1px solid #e0e0e0;
	}
	#guideline span{
		color: #ADABAB;
		font-weight: bold;
		cursor: pointer;
	}
	#managetable{
		text-align: center;
		margin-bottom: 10px;
		width: 800px;
	}
	#managetable th{
		height: 45px;
		background-color: rgba(173,171,171,.2);
	}
	#managetable td{
		border-bottom: 1px solid #FEFCF8;
		height: 30px;
	}
	#btntable{
		width: 700px;
		text-align: center;
	}
	.inputb{
		border-bottom: #999999 1px solid;
		border-left: #cecece 1px solid;
		border-right: #999999 1px solid;
		border-top: #cecece 1px solid;
		color: #000000;
		font-size: 9pt;
		background-color: #ededed;
		height:25px;
		font-family: "맑은 고딕";
	}
</style>
<script type="text/javascript">
	function searchCheck(){
		if(document.search.keyField.value=='email' || document.search.keyField.value=='name' ||
		   document.search.keyField.value=='phone'){
			if(document.search.keyWord.value==''){
				alert('검색어를 입력하세요.');
				document.search.keyWord.focus();
				return false;
			}
		}
	}
	
	function deleteMember(size){
		for(var i=0; i<size-1; i++){
			var check = document.getElementById('checkBox_'+i).checked;
			if(check == true){
				document.getElementById('check_'+i).value = 1;
			}
		}
		var form = document.getElementById('deleteForm');
		form.submit();
	}
	</script>
</head>
<body>
<div id="wrap_detail">
	<div id="title_img">
		<img src="./images/admin/admin_title.png">
	</div>
	<p style="height: 10px"></p>
	<div id="list">
		<ul id="mypage_list_tab">
			<li>
				<form action="memberList.do" method="post">
					<input type="hidden" name="email" value="${email}">
					<input type="submit" value="회원관리" class="my_btn" style="cursor: pointer">
				</form>
			</li>
			<li>
				<input type="button" value="구매관리" class="my_btn" style="cursor: pointer"
					   onclick="location.href='purchaseList.do'">
			</li>
			<li>
				<form action="<%=contextPath%>/serviceList.do" method="post">
					<input type="hidden" name="email" value="${email}">
					<input type="submit" value="문의 내역 관리" class="my_btn" style="cursor: pointer">
				</form>
			</li>
			<li>
				<input type="button" value="예약관리" class="my_btn" style="cursor: pointer"
					   onclick="location.href='reservationList.do'">
			</li>
		</ul>
	</div>
	<div>
		<table style="width: 800px">
			<tr>
				<td style="padding-left: 7px; width: 598px">
					<input type="button" value="영구제명" class="inputb" onclick="deleteMember(${size-1})">
				</td>
				<td>
				<form action="memberList.do" name="search" method="get" onsubmit="return searchCheck();">
					<table>
						<tr>
							<td>
								<select name="keyField">
									<option value="all">전체</option>		
									<option value="email">이메일</option>
									<option value="name">이름</option>
									<option value="phone">연락처</option>
								</select>
							</td>
							<td>
								<input type="text" size="16" name="keyWord">
							</td>
							<td>
								<input type="submit" value="검색" class="inputb">
							</td>
						</tr>
					</table>
					</form>
				</td>
			</tr>
		</table>
	</div>
	<div>
	<form id="deleteForm" action="manageMember.do" name="manager" method="POST">
	<input type="hidden" name="size" value="${size-1}">
		<table id="managetable">
			<tr>
				<th style="width: 20px;"><input type="checkbox"></th>
				<th style="width: 150px;">EMAIL</th>
				<th style="width: 50px;">이 름</th>
				<th style="width: 40px;">성 별</th>
				<th style="width: 100px;">연락처</th>
				<th style="width: 100px;">가입일</th> 
				<th style="width: 110px;">생년월일</th>
				<th>비밀번호</th>
			</tr>
			<c:if test="${size>0}">
				<c:forEach var="i" begin="0" end="${size-1}" step="1">
					<c:if test="${memberList[i].email != 'admin'}">
					<tr>
						<td><input type="checkbox" id="checkBox_${i}">
							<input type="hidden" id="check_${i}" name="check_${i}" value="0"></td>
						<td><input type="hidden" name="email_${i}" value="${memberList[i].email}">
							${memberList[i].email}</td>
						<td>${memberList[i].name}</td>
						<td>${memberList[i].gender}</td>
						<td>${memberList[i].phone}</td>
						<td>${memberList[i].regdate}</td>
						<td>${memberList[i].birth}</td>
						<td style="text-overflow:ellipsis; overflow:hidden; width: 200px;">
							${memberList[i].passwd}
						</td>
					</tr>
					</c:if>
				</c:forEach>
			</c:if>
			<c:if test="${count <= 1}">
				<tr>
					<td colspan="8">등록된 회원이 없습니다.</td>
				</tr>
			</c:if>
		</table>
		</form>
		<br>
		<c:if test="${count > 1}">
			<table id="btntable">
				<tr>
					<td class="align-center" style="text-align: center;">${pagingHtml}</td>
				</tr>
			</table>
		</c:if>
	</div>
</div>	
</body>
</html>